<div class="form">

<?php
        $form = $this->beginWidget('CActiveForm', array(
            'id' => 'game-version-form',
            'enableAjaxValidation' => true,
            'htmlOptions' => array(
                'enctype' => 'multipart/form-data',
            )
            ));
?>

	<p class="note">Fields with <span class="required">*</span> are required.</p>

	<?php echo CHtml::errorSummary($model); ?>
        
        <div class="row">
            <?php
            $dropDownValue = '';
            if(isset($gameModel)){
                $dropDownValue = array();
                $gamePlatform = GamePlatform::model()->findAll('game_id ='.$gameModel->id);
                $j2me_id = 0;
                if (isset($gamePlatform))
                    foreach($gamePlatform as $item){
                        if($item->platform->code_identifier == 'j2me')
                            $j2me_id = $item->id;
                        $dropDownValue[$item->id] = $item->platform->name;                                        
                    }
                ?>
                <?php echo CHtml::label('Nền tảng:', 'platform') ?><br>
                <?php echo $form->dropDownList($model,'game_platform_id', $dropDownValue, array('class'=>'bb')); ?>    
            <?php } ?>
        </div>

	<div class="row">
		<?php echo $form->labelEx($model,'core_version'); ?>
		<?php echo $form->textField($model,'core_version',array('size'=>40,'maxlength'=>128)); ?>
		<?php echo $form->error($model,'core_version'); ?>
	</div>
        
        <div class="row">
		<?php echo $form->labelEx($model,'build_version'); ?>
		<?php echo $form->textField($model,'build_version',array('size'=>40,'maxlength'=>128)); ?>
		<?php echo $form->error($model,'build_version'); ?>
	</div>
        
        <div class="row">
		<?php echo $form->labelEx($model,'code_revision'); ?>
		<?php echo $form->textField($model,'code_revision',array('size'=>40,'maxlength'=>128)); ?>
		<?php echo $form->error($model,'code_revision'); ?>
	</div>
                        
        <div class="row">
            <?php echo CHtml::label('File1:', 'file_path') ?>
            <br>
            <?php echo CHtml::fileField('file_path'); ?>
            <br>
        </div>
        <?php if(isset($model->id)): ?>
        <div><b>File_path: </b><?php echo $model->file_path; ?></div>
        <?php endif;?>
        
        <div class="row" style="display:none" id="file_path2">
            <?php echo CHtml::label('File2:(jad)', 'file_path2') ?>
            <br>
            <?php echo CHtml::fileField('file_path2'); ?>
            <br>
        </div>                
        <?php if(isset($model->id)): ?>
        <div><b>File_path2: </b><?php echo $model->file_path2; ?></div>
        <?php endif;?>

	<div class="row">
		<?php echo $form->labelEx($model,'description'); ?>
                <?php echo CHtml::activeTextArea($model,'description',array('rows'=>10, 'cols'=>70)); ?>		
		<?php echo $form->error($model,'description'); ?>
	</div>     
        
        <div class="row">
		<?php echo $form->labelEx($model,'enabled'); ?>
		<?php echo $form->dropDownList($model,'enabled',array('1'=>'Đúng','0'=>'Không')); ?>
		<?php echo $form->error($model,'enabled'); ?>
	</div> 
        
        <div class="row">
		<?php echo $form->labelEx($model,'visible'); ?>
		<?php echo $form->dropDownList($model,'visible',array('1'=>'Hiện thị','0'=>'Ẩn')); ?>
		<?php echo $form->error($model,'visible'); ?>
	</div>                
        
	<div class="row buttons">
		<?php echo CHtml::submitButton($model->isNewRecord ? 'Create' : 'Save'); ?>
	</div>
        
<?php $this->endWidget(); ?>

</div><!-- form -->

<script type="text/javascript">
$(document).ready(function(){
    var j2me_id = <?php echo $j2me_id; ?>;
    var option_id = $('#GameVersion_game_platform_id').val();
    if(option_id == j2me_id)
         $('#file_path2').show();    
    $('#GameVersion_game_platform_id').change(function(){
        option_id = $(this).val();
        if(option_id == j2me_id){
            $('#file_path2').show();
        }else{
            $('#file_path2').hide();
        }
            
    })
})
</script>